#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const int N=1e3+10;
#define INF 0x3f3f3f3f;
typedef long long int ll;
#define close(); std::ios::sync_with_stdio(false);cin.tie(0),cout.tie(0);
//----------------------------------------------------------------------------//
int n;
int cur[N];
vector<int> ans;
int main()
{
	close();
	cin>>n;
	for(int i=0;i<n;i++) cout<<cur[i];
	
	vector<int> a;
	vector<int> b;
	a.push_back(cur[0]);
	
	for(int i=1;i<n;i++)
	{
		if(cur[i]<a[a.size()-1]) a.push_back(cur[i]);
		else if(cur[i]>a[a.size()-1]&&(b.size()==0||cur[i]<a[b.size()-1])) b.push_back(cur[i]);
		else 
		{
			ans.push_back(a.size());
			vector<int> t;
			vector<int> tt;
			for(int j=b.size()-1;j>=0;j--)
			{
				if(b[j]>cur[i]) t.push_back(b[j]);
				else tt.push_back(b[j]);
			}
			t.push_back(cur[i]);
			a=t;
			b=tt;
		}
	}	
	
	ans.push_back(a.size());
	ans.push_back(b.size());
	sort(all(a));
	cout<<a.size()<<" "<<a[a.size()-1]<<'\n';
	return 0;
}
